package com.myapp.web.struts2.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.AbstractUITag;
import com.myapp.web.struts2.components.FieldTemplateBean;
import com.opensymphony.xwork2.util.ValueStack;

public class FieldTemplateTag extends AbstractUITag {
	
	private static final long serialVersionUID = -7590308339187937413L;

	private boolean escape = true;
    
    private String template ;
    
    protected String fieldName;

    public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new FieldTemplateBean(stack, req, res);
    }

    protected void populateParams() {
        super.populateParams();

        FieldTemplateBean templateBean = ((FieldTemplateBean) component);
        templateBean.setFieldName(this.fieldName);
        templateBean.setEscape(escape);
        templateBean.setTemplate(template);        
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public void setEscape(boolean escape) {
        this.escape = escape;
    }
    
    public void setTemplate(String template) {
        this.template = template;
    }
}
